package com.iaz.tech.tools.ai.neuron.exec;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.iaz.tech.tools.ai.neuron.runtime.INeuronRuntimeAbility;
import com.iaz.tech.tools.uml.IUMLNeuronAble;
import com.iaz.tech.tools.uml.relationship.Relationship;
import com.iaz.tech.tools.uml.relationship.impl.NeuronExtendRelationship;

import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper=false)
@Data
public class NeuronExtendCodeGenerator extends NeuronCodeGenerator{
    /**
     * 日志
     */
	private final static Logger logger = (Logger) LoggerFactory.getLogger(NeuronExtendCodeGenerator.class);

    public NeuronExtendCodeGenerator() {
        super();
    }

    public NeuronExtendCodeGenerator(INeuronRuntimeAbility runtime) {
        super();
        this.setRuntime(runtime);
    }
    /**
     * 转换为扩展关系
     */
    @Override
    public Relationship toRelationship(IUMLNeuronAble uml) throws Exception {
        if (uml == null) {
            logger.error("uml不能为null.");
            throw new IllegalArgumentException("uml不能为null");
        }
        if (!(uml instanceof NeuronExtendRelationship)){
            throw new IllegalArgumentException("uml必须为 NeuronExtendRelationship.");
        }
        return (NeuronExtendRelationship) uml;        
    }

}
